<!-- <template>
   <view class="content">
    <view class="data-list" v-if="dataList.length>0">
            <view class="data-item" v-for="(item,index) in dataList" :key="index">
                <view class="ac-title">{{item.title}}</view>
                <view class="ac-time"><u-icon name="clock" color="#999999"></u-icon> {{item.activity_time}}</view>
                <view class="ac-address"><u-icon name="map" color="#999999"></u-icon> {{item.address}}</view>
		
                <view class="btn-box">
                    <u-button @click="toPage('/pages/user/en_detail',{en_id:item.id})" shape="circle" type="primary" text="查看二维码" size="small"></u-button>
                </view>
            </view>
        </view>
        <u-empty v-else mode="data" text="暂无参与活动" ></u-empty>
        <image class="bottom-bg" src="@/static/img/bg2.png"></image>
    </view>
</template> -->
<template>
    <view class="content">
        <view class="data-list" v-if="dataList.length>0">
            <view class="data-item" v-for="(item,index) in dataList" :key="index">
                <view class="ac-title">{{item.activity.title}}</view>
                <view class="ac-time"><u-icon name="clock" color="#999999"></u-icon> {{item.activity.activity_time}}</view>
                <view class="ac-address"><u-icon name="map" color="#999999"></u-icon> {{item.activity.address}}</view>
                <view class="btn-box">
                    <u-button @click="toPage('/pages/user/en_detail',{en_id:item.id})" shape="circle" type="primary" text="查看二维码" size="small"></u-button>
                </view>
            </view>
        </view>
        <u-empty v-else mode="data" text="暂无参与活动" ></u-empty>
        <image class="bottom-bg" src="@/static/img/bg2.png"></image>
    </view>
</template>

<script>
// export default {
//         data() {
//             return {
//                 dataList:[],
//                 page:1, // 当前页
//                 totalPage:1,
//                 per_page:8,
//             }
//         },
//         onLoad(e) {
//             this.getData()
//         },
//         onPullDownRefresh() {
//             this.page = 1
//             this.dataList = []
//             this.getData()
//         },
//         onReachBottom() {
//             if (this.page == this.totalPage) return false
//             this.page = this.page + 1
//             this.getData()
//         },
//         methods: {
//             getData(){
//                 let params = {
//                     per_page: this.per_page,
//                     page: this.page,
//                 }
//                 uni.$u.http.get('/enrollment/index',{params: params}).then((res) => {
//                     if(res.code==1){
//                         this.page = res.data.current_page
//                         this.totalPage = res.data.last_page
//                         this.dataList = [...this.dataList,...res.data.data]
//                         uni.stopPullDownRefresh()
//                     }
//                 })
//             },
// 			showData(id){
// 				let params2 = {
// 					acid:id,
// 				}
// 				uni.$u.http.get('/enrollment/index3', {
// 					params: params2
// 				}).then((res) => {
// 					if (res.code == 1) {
// 						this.data2 =res.data
// 					}
// 				})
// 			}
				
//         },
//     }

export default {
        data() {
            return {
                dataList:[],
                page:1, // 当前页
                totalPage:1,
                per_page:8,
            }
        },
        onLoad(e) {
            this.getData()
        },
        onPullDownRefresh() {
            this.page = 1
            this.dataList = []
            this.getData()
        },
        onReachBottom() {
            if (this.page == this.totalPage) return false
            this.page = this.page + 1
            this.getData()
        },
        methods: {
            getData(){
                let params = {
                    per_page: this.per_page,
                    page: this.page,
                }
                uni.$u.http.get('/enrollment/index',{params: params}).then((res) => {
                    if(res.code==1){
                        this.page = res.data.current_page
                        this.totalPage = res.data.last_page
                        this.dataList = [...this.dataList,...res.data.data]
                        uni.stopPullDownRefresh()
                    }
                })
            }
        },
    }
</script>

<style lang="scss">
.content{
        background-color: rgb(249,249,249);
        height: 100vh;
        padding: 10px;
        .data-list{
            position: relative;
            z-index: 2;
            padding-top: 10px;
            .data-item{
                margin-bottom: 10px;
                background-color: #FFFFFF;
                padding: 10px;
                border-radius: 8px;
                .ac-title{
                    font-size: 18px;
                    font-weight: 600;
                    color: rgba(51, 51, 51, 1);
                    margin-bottom: 10px;
                }
                .ac-time,.ac-address{
                    font-size: 12px;
                    font-weight: 400;
                    line-height: 2;
                    color: #999999;
                    display: flex;
                    /deep/.u-icon{
                        margin-right: 4px;
                    }
                }
                .btn-box{
                    margin-top: 10px;
                }
            }
        }
        .bottom-bg{
            z-index: 1;
            position: fixed;
            left: 10vw;
            bottom: 0;
            width: 80vw;
            height: calc(80vw / 520 * 346 );
        }
    }
</style>
